<%@ page language="java" import="java.util.*,com.xq.shop.po.Role" pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>" />
<jsp:include page="/jsp/admin/common.jsp" />
<jsp:include page="/jsp/formHead.jsp" />
<jsp:include page="/jsp/tableHead.jsp" />
<jsp:include page="/jsp/listHead.jsp" />
<script type="text/javascript" src="<%=basePath%>resource/admin_js/category.js" defer="defer"></script>
<link rel="stylesheet" type="text/css" href="<%=basePath%>resource/admin_css/product.css" />
<script type="text/javascript">
$().ready(function(){

	$("#backButton").click(function(){
		location.href = basePath + "jsp/admin/product/category_list.jsp";
	});
	
	$("#form_edit").validate({	//验证配置
		rules : {
			name : "required",
			seq : {
				required : true,
				digits : true
			}
		},
		messages : {
			parent_id : {required : "必选"}
		}
	});

	//判断是否是编辑状态
	if(${!empty entity.id }){
		$("div.path").append("<span>商品分类参数修改</span>");
	} else {
		$("div.path").append("<span>商品分类参数创建</span>");
	}

	QListBox.init("#product_category", {css:{width: "188px"}, defaultItem:{text:"请选择",value:-1}});
	var $search = QSearch.init("<%=basePath%>admin/category_list.do", "json");
	$search.setPageNum(1);
	$search.setPageSize(100);
	$search.onSearch(function(_result){
		var list = category_sort(_result.page),
			items = [];
		for(var i=0, len=list.length; i<len; i+=1){
			
			if(list[i]["grade"] == 1){
				items.push({value:list[i]["id"], text: list[i]["name"], disabled : true});
			} else if(list[i]["grade"] == 2){
				items.push({value:list[i]["id"], text: list[i]["name"], "class": "category_2nd"});
			}
		}
		QListBox.get("#product_category").refresh(items);
		QListBox.get("#product_category").onSelected(function(_value){
			$("input[name='category_id']").val(this.getValue());
			//initProductParam();
		});
	});
	$search.doSearch();

	QListBox.init("#param_type", {css:{width: "188px"}, defaultItem:{text:"默认",value:1}});
});
</script>
</head>
<body>
	<div class="path">
		<a href="">首页</a> &raquo;
	</div>
	<form id="form_edit" method="post" action="<%=basePath %>admin/categoryParam_save.do">
		<table class="input tabContent">
			<tr>
				<th>
					<span class="requiredField">*</span>商品分类:
				</th>
				<td>
					<div id="product_category"></div>
					<input name="category_id" type="hidden" value=""/>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField">*</span>名称:
				</th>
				<td>
					<input type="hidden" name="id" value=""/>
					<input type="text" name="name" class="text" maxlength="200" value="${entity.name}"/>
				</td>
			</tr>
			<tr>
				<th>
					参数类型:
				</th>
				<td>
					<div id="param_type"></div>
					<input name="type" type="hidden" value="1"/>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField">*</span>顺序:
				</th>
				<td>
					<input type="text" name="seq" class="text" maxlength="200" value="${entity.seq }"/>
				</td>
			</tr>
			<tr>
				<th>
					&nbsp;
				</th>
				<td>
					<input type="submit" class="button" value="确定" />
					<input type="button" id="backButton" class="button" value="返回"/>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>